import React from 'react'
import { ConfigProvider  } from 'antd'
import moment from 'moment'
import 'moment/locale/zh-cn'
import zhCN from 'antd/es/locale/zh_CN';
import elementResizeDetectorMaker from 'element-resize-detector'
import s from './index.less'
const erd=elementResizeDetectorMaker()
moment.locale('zh-cn')

class Box extends React.Component{
  componentDidMount() {
    erd.listenTo(this.body, (el) => {
      window.parent.postMessage(el.offsetHeight, '*');
    })
  }
  render() {
    return (
      <ConfigProvider
        locale={zhCN}
        getPopupContainer={node => node?node.parentElement:document.body}
      >
        <div className={s['body']} ref={ref => this.body = ref}>
          {this.props.children}
        </div>
      </ConfigProvider>
    )
  }
}
export default Box
